# -*- coding:utf-8 -*-
"""Created By Corvo"""

import functools


# 执行一次的函数
def execute_once(func):
    """
    执行一次的函数\n
    - 类方法使用
    """

    @functools.wraps(func)
    def discard(*args, **kwargs):
        pass

    @functools.wraps(func)
    def execute(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        finally:
            setattr(args[0], func.__name__, discard)

    return execute
